.class final Lcom/burstly/lib/exception/HeapFileDumpHandler;
.super Ljava/lang/Object;
.source "HeapFileDumpHandler.java"

# interfaces
.implements Ljava/lang/Thread$UncaughtExceptionHandler;


# static fields
.field private static final DUMP_FILE_PATH:Ljava/lang/String; = null

.field private static final LOG:Lcom/burstly/lib/util/LoggerExt; = null

.field private static final TAG:Ljava/lang/String; = "HeapFileDumpHandler"


# direct methods
.method static constructor <clinit>()V
    .locals 2

    .prologue
    .line 40
    invoke-static {}, Lcom/burstly/lib/util/LoggerExt;->getInstance()Lcom/burstly/lib/util/LoggerExt;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/exception/HeapFileDumpHandler;->LOG:Lcom/burstly/lib/util/LoggerExt;

    .line 50
    new-instance v0, Ljava/lang/StringBuilder;

    invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V

    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v1

    invoke-virtual {v1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    const-string v1, "/burstly_oom_dump.hprof"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/exception/HeapFileDumpHandler;->DUMP_FILE_PATH:Ljava/lang/String;

    return-void
.end method

.method constructor <init>()V
    .locals 0

    .prologue
    .line 35
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method


# virtual methods
.method public uncaughtException(Ljava/lang/Thread;Ljava/lang/Throwable;)V
    .locals 8
    .parameter "t"
    .parameter "e"

    .prologue
    const/4 v3, 0x0

    .line 55
    invoke-virtual {p2}, Ljava/lang/Throwable;->getCause()Ljava/lang/Throwable;

    move-result-object v0

    .line 56
    .local v0, cause:Ljava/lang/Throwable;
    instance-of v4, p2, Ljava/lang/OutOfMemoryError;

    if-nez v4, :cond_0

    instance-of v4, v0, Ljava/lang/OutOfMemoryError;

    if-eqz v4, :cond_2

    :cond_0
    const/4 v2, 0x1

    .line 57
    .local v2, isToDump:Z
    :goto_0
    if-eqz v2, :cond_1

    .line 59
    :try_start_0
    invoke-static {}, Lcom/burstly/lib/util/Utils;->canWriteToSDCard()Z

    move-result v4

    if-eqz v4, :cond_3

    .line 60
    sget-object v4, Lcom/burstly/lib/exception/HeapFileDumpHandler;->DUMP_FILE_PATH:Ljava/lang/String;

    invoke-static {v4}, Landroid/os/Debug;->dumpHprofData(Ljava/lang/String;)V

    .line 70
    :cond_1
    :goto_1
    return-void

    .end local v2           #isToDump:Z
    :cond_2
    move v2, v3

    .line 56
    goto :goto_0

    .line 62
    .restart local v2       #isToDump:Z
    :cond_3
    sget-object v4, Lcom/burstly/lib/exception/HeapFileDumpHandler;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v5, "HeapFileDumpHandler"

    const-string v6, "Can not save heap dump file because SD card is not availale or it is read only."

    const/4 v7, 0x0

    new-array v7, v7, [Ljava/lang/Object;

    invoke-virtual {v4, v5, v6, v7}, Lcom/burstly/lib/util/LoggerExt;->logInfo(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_1

    .line 65
    :catch_0
    move-exception v1

    .line 66
    .local v1, ex:Ljava/io/IOException;
    sget-object v4, Lcom/burstly/lib/exception/HeapFileDumpHandler;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v5, "HeapFileDumpHandler"

    const-string v6, "Can not save heap dump file"

    new-array v7, v3, [Ljava/lang/Object;

    invoke-virtual {v4, v5, v6, v7}, Lcom/burstly/lib/util/LoggerExt;->logWarning(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 67
    sget-object v4, Lcom/burstly/lib/exception/HeapFileDumpHandler;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v5, "HeapFileDumpHandler"

    invoke-static {p2}, Landroid/util/Log;->getStackTraceString(Ljava/lang/Throwable;)Ljava/lang/String;

    move-result-object v6

    new-array v3, v3, [Ljava/lang/Object;

    invoke-virtual {v4, v5, v6, v3}, Lcom/burstly/lib/util/LoggerExt;->logWarning(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    goto :goto_1
.end method
